﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;


namespace THO7AlgoritmTimerApplication {
    class stretch : VisionAlgorithm {
        int height = 0;
        int width = 0;
        public stretch(String name,int h, int w) : base(name) {
            height = h;
            width = w;
        }
        public override Bitmap DoAlgorithm(Bitmap sourceImage) {
            int sourceWidth = sourceImage.Width;
            int sourceHeight = sourceImage.Height;
            float nPercentH = 0;
            float nPercentW = 0;
            nPercentH = ((float)height / (float)sourceHeight);
            nPercentW = ((float)width / (float)sourceWidth);
            int destWidth = (int)(sourceWidth * nPercentW);
            int destHeight = (int)(sourceHeight * nPercentH);
            Bitmap b = new Bitmap(destWidth, destHeight);
            Graphics g = Graphics.FromImage((Image)b);
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            g.DrawImage(sourceImage, 0, 0, destWidth, destHeight);
            g.Dispose();
            return b;
        }
    }
}